<?php
class Admin_Form_Point extends Zend_Form {
	
	const POSITION = 'Vị trí hiển thị';
	const PAGE = 'Trang hiển thị';
	const POINT = 'Điểm';
	const SAVE = 'Save';
	const RESET = 'Reset';
	
	private function createIdElement() {
		$id = new Zend_Form_Element_Hidden('id');
		$id->addFilter('Int');
		return $id;
	}
	
	private  function createPageElement() {
		$page = new Zend_Form_Element_Select('page_id');
		$page->setLabel(self::PAGE)
			 ->setAttribs(array("key" => "value", "disable" => "true"))
			 ->addFilter('StringTrim')
			 ->setRegisterInArrayValidator(false);
		return $page;
	}
	
	private  function createPositionElement() {
		$position = new Zend_Form_Element_Select('position_id');
		$position->setLabel(self::POSITION)
				 ->setAttribs(array("key" => "value", "disable" => "true"))
				 ->addFilter('StringTrim')
				 ->setRegisterInArrayValidator(false);
		return $position;
	}
	
	private function createPointElement() {
		$point = new Zend_Form_Element_Text('point');
		$point->setLabel(self::POINT)
			  ->setRequired(true)
			  ->addFilter('StringTrim')
			  ->addValidator('NotEmpty', true)
			  ->addValidator('Digits')
			  ->setAttribs(array("maxlength" => "9"));
		return $point;
	}
	
	private function createSubmitElement() {
		$submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton')
        	   ->removeDecorator('DtDdWrapper')
        	   ->setLabel(self::SAVE)
        	   ->setAttrib("class", "btn btn-large btn-primary ");
       	return $submit;
	}
	
	private function createResetElement() {
		$reset = new Zend_Form_Element_Reset('reset'); 
		$reset->setAttrib('id', 'resetbutton')
			  ->removeDecorator('DtDdWrapper')
			  ->setLabel(self::RESET)
			  ->setAttrib("class", "btn btn-large");
		return $reset;	  
	}
	
    public function init() {
        $this->setName('point');
        $this->setMethod('post');

		$id = $this->createIdElement();
		$position = $this->createPositionElement();
		$page = $this->createPageElement();
		$point = $this->createPointElement();
		$submit = $this->createSubmitElement();
		$reset = $this->createResetElement();
        
        $this->addElements(array($id, $page, $position, $point, $submit, $reset));
        
		$this->addDisplayGroup(array('submit', 'reset'), 'buttons');
		$dg = $this->getDisplayGroup('buttons');
		$dg->removeDecorator('Fieldset');
		$dg->removeDecorator('HtmlTag');      
    }
	
}
?>